{% extends 'base.html' %}

{% block title %}添加用户{% endblock %}

{% block content %}
<form class="layui-form" action="" method="post">
	<div class="layui-container">
	  <div class="layui-row">
	    <div class="layui-col-md4">
			  <div class="layui-form-item">
			    <label class="layui-form-label">用户名</label>
			    <div class="layui-input-block">
			      <input type="text" name="username" required  lay-verify="required" value="{{ username }}" placeholder="请输入用户名" autocomplete="off" class="layui-input">
			    </div>
			  </div>
	    </div>
		  <div class="layui-col-md8"></div>
	  </div>

	  <div class="layui-form-item">
	    <label class="layui-form-label">密码</label>
	    <div class="layui-input-inline">
	      <input type="password" name="password" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
	    </div>
	    <div class="layui-form-mid layui-word-aux"></div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">确认密码</label>
	    <div class="layui-input-inline">
	      <input type="password" name="password1" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
	    </div>
	    <div class="layui-form-mid layui-word-aux"></div>
	  </div>

	  <div class="layui-row">
	    <div class="layui-col-md4">
			  <div class="layui-form-item">
			    <label class="layui-form-label">邮箱</label>
			    <div class="layui-input-block">
			      <input type="text" name="email" required  lay-verify="required|email" placeholder="请输入邮箱" value="{{ email }}" autocomplete="off" class="layui-input">
			    </div>
			  </div>
	    </div>
		  <div class="layui-col-md8"></div>
	  </div>

		<div class="layui-form-item">
	    <label class="layui-form-label">所属组</label>
	    <div class="layui-input-inline">
	      <select name="group">
	        <option value="">请选择组</option>
		      {% for group in groups %}
			      {% if asset.group == group.id %}
		        <option value="{{ group.id }}" selected="">{{ group.name }}</option>
			      {% else %}
		        <option value="{{ group.id }}">{{ group.name }}</option>
			      {% endif %}
		      {% endfor %}
	      </select>
	    </div>
		</div>

	  <div class="layui-form-item">
	    <label class="layui-form-label">权限</label>
	    <div class="layui-input-block">
	      <input type="radio" name="is_superuser" value="True" title="超级用户">
	      <input type="radio" name="is_superuser" value="False" title="普通用户" checked>
	    </div>
	  </div>

	  <div class="layui-form-item">
	    <label class="layui-form-label">是否禁用</label>
	    <div class="layui-input-block">
	      <input type="checkbox" name="switch" lay-skin="switch" >
		    {% csrf_token %}
	    </div>
	  </div>
		{% if error %}
		<div class="layui-row layui-col-space10">
      <div class="layui-col-md1">
	      <i class="layui-icon"></i>
      </div>
			<div class="layui-col-md4">
	      <i class="layui-icon" style="font-size: 30px; color: #FFB800;">&#xe69c;: {{ error }}</i>
			</div>
		</div>
		{% endif %}
	  <div class="layui-form-item">
	    <div class="layui-input-block">
	      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
	      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
	    </div>
	  </div>
	</div>
</form>

<script>
//Demo
layui.use('form', function(){
  var form = layui.form;

  //监听提交
  form.on('submit(formDemo)', function(data){
{#    layer.msg(JSON.stringify(data.field));#}
    return true;
  });
});
</script>
{% endblock %}